#!/usr/bin/env python

from webform_class import WebForm
import sys

def list_destinations ( liwe, id = '' ):
	"""
	:INPUT:
		- id:			SAFE_NUMBER
	"""
	wf = WebForm ( liwe )
	return { "destinations" : wf.list_destinations ( id ) }

def list_form_destinations ( liwe, fname = '' ):
	"""
	:INPUT:
		- fname: form name	SAFE_DB_STRING
	"""
	wf = WebForm ( liwe )
	return { "destinations" : wf.list_form_destinations ( fname ) }

def get_form_fields ( liwe, fname = '', id = '' ):
	"""
	:INPUT:
		- fname: form name	SAFE_DB_STRING
		- id:			SAFE_NUMBER
	"""
	wf = WebForm ( liwe )
	return { "ffields" : wf.get_form_fields ( fname, id ), 'form' : wf.main_get ( fname ) }

def list_forms ( liwe ):
	"""
	:INPUT:
	"""
	wf = WebForm ( liwe )
	return { "forms_list" : wf.list_forms () }

def send_email ( liwe, id_dest, sender_email, message_body ):
	"""
	:INPUT:

		- id_dest:		SAFE_NUMBER
		- sender_email:		SAFE_EMAIL
		- message_body:		SAFE_DB_STRING
	"""
	wf = WebForm ( liwe )
	return wf.send_mail ( id_dest, sender_email, message_body )

def send_form ( liwe, kwargs ):
	"""
	:INPUT:
	"""
	wf = WebForm ( liwe )
	form_vals = kwargs
	return wf.send_form ( form_vals )

def get_templates ( liwe ):
	"""
	:INPUT:
	"""
	wf = WebForm ( liwe )
	return { "templates" : wf.get_templates () }
